require "date.rb"

if ARGV.size != 4
  puts "usage: ruby timediff.rb <day> <month> <year> <header_string>"
  puts "example: ruby timediff.rb 28 02 1985  \"Time since my birth\""
  puts "Given " + ARGV.size.to_s + " args"
  exit
end


day = ARGV[0].to_i;
mon = ARGV[1].to_i;
yea = ARGV[2].to_i;

puts ARGV[3]

if (day == 0 || mon == 0 || yea == 0) 
  puts "Invalid date d:" + ARGV[1] + " m:" + ARGV[2] + " y:" + ARGV[3]
  exit
end

# DateTime.new(year, month, day)
deadline = DateTime.new(yea, mon, day)


now = DateTime::now()
diff = deadline - now
hours, mins, secs, ignore_fractions = Date::day_fraction_to_time(diff)
days = (hours / 24).floor.to_i
hours -= (days*24)

puts days.to_s + " days, " + hours.to_s + " hours and " + mins.to_s + " minutes left"